import { UserConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { ViteAliases } from "vite-aliases";
import postcssPresetEnv from "postcss-preset-env";
import Icons from "unplugin-icons/vite";
import IconResolver from "unplugin-icons/resolver";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";

// https://vitejs.dev/config/
const config: UserConfig = {
  base: "./",
  envPrefix: "ENV_",
  css: {
    modules: {
      localsConvention: "camelCase",
      scopeBehaviour: "local",
      hashPrefix: "hzj",
      generateScopedName: "[local]_[hash:5]",
    },
    preprocessorOptions: {
      less: {
        math: "always",
        globalVars: {
          // 全局变量
        },
      },
    },
    devSourcemap: true,
    postcss: {
      plugins: [postcssPresetEnv()],
    },
  },
  plugins: [
    vue(),
    ViteAliases(),
    AutoImport({
      resolvers: [
        ElementPlusResolver(),
        IconResolver({
          prefix: "i",
        }),
      ],
    }),
    Components({
      resolvers: [
        ElementPlusResolver(),
        IconResolver({
          enabledCollections: ["ic", "fluent", "carbon","uil"],
        }),
      ],
    }),
    Icons({
      // experimental
      autoInstall: true,
    }),
  ],
};

export default config;
